package com.babyqiao.wallpaper.manager.service.impl;

import com.babyqiao.wallpaper.manager.dao.AlbumTagRelMapper;
import com.babyqiao.wallpaper.manager.entity.AlbumTagRel;
import com.babyqiao.wallpaper.manager.entity.WallpaperTag;
import com.babyqiao.wallpaper.manager.dao.WallpaperTagMapper;
import com.babyqiao.wallpaper.manager.service.IAlbumTagRelService;
import com.babyqiao.wallpaper.manager.service.IWallpaperTagService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author QLZ
 * @since 2021-02-20
 */
@Service
public class WallpaperTagServiceImpl extends ServiceImpl<WallpaperTagMapper, WallpaperTag> implements IWallpaperTagService {

    @Autowired
    IAlbumTagRelService albumTagRelService;

    /**
     * 删除tag,同时删除关联专辑表中的关系
     *
     * @param id : 要删除的tag id
     * @Author QLZ
     * @Date 2021/2/20
     * @return: boolean 是否删除成功
     */
    @Override
    public boolean delTagService(String id) {
        QueryWrapper<AlbumTagRel> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("tag_id",id);
        albumTagRelService.remove(queryWrapper);

        return this.removeById(id);
    }
}
